//package com.bestcem.xm.common.core.config.mybatis.typehandler;
//
//import org.apache.ibatis.type.BaseTypeHandler;
//import org.apache.ibatis.type.JdbcType;
//import org.apache.ibatis.type.MappedJdbcTypes;
//import org.apache.ibatis.type.MappedTypes;
//
//import java.sql.*;
//import java.time.LocalDateTime;
//
///**
// * ShardingSphere不支持getObject，需要自定义LocalDateTime类型转换（参照mybatis-typehandlers-jsr310 v1.0.2）
// *
// * @author zhangfeng <feng.zhang@idiaoyan.com>
// * @version v1.0
// * @date 2021/9/14 17:20
// */
//@MappedTypes(LocalDateTime.class)
//@MappedJdbcTypes(value = {JdbcType.TIME, JdbcType.DATE, JdbcType.TIMESTAMP}, includeNullJdbcType = true)
//public class LocalDateTimeTypeHandler extends BaseTypeHandler<LocalDateTime> {
//
//    @Override
//    public void setNonNullParameter(PreparedStatement ps, int i, LocalDateTime parameter, JdbcType jdbcType)
//            throws SQLException {
//        ps.setTimestamp(i, Timestamp.valueOf(parameter));
//    }
//
//    @Override
//    public LocalDateTime getNullableResult(ResultSet rs, String columnName) throws SQLException {
//        Timestamp timestamp = rs.getTimestamp(columnName);
//        return getLocalDateTime(timestamp);
//    }
//
//    @Override
//    public LocalDateTime getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
//        Timestamp timestamp = rs.getTimestamp(columnIndex);
//        return getLocalDateTime(timestamp);
//    }
//
//    @Override
//    public LocalDateTime getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
//        Timestamp timestamp = cs.getTimestamp(columnIndex);
//        return getLocalDateTime(timestamp);
//    }
//
//    private static LocalDateTime getLocalDateTime(Timestamp timestamp) {
//        if (timestamp != null) {
//            return timestamp.toLocalDateTime();
//        }
//        return null;
//    }
//}